package com.sinosoft.weixin.service.impl;

import com.sinosoft.weixin.db.entity.User;
import com.sinosoft.weixin.db.entity.UserExample;
import com.sinosoft.weixin.db.mapper.UserMapper;
import com.sinosoft.weixin.service.UserService;
import com.sinosoft.weixin.utils.MessageDigestUtils;
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by huzhengying on 2017/11/12.
 */
@Service
public class UserServiceImpl implements UserService{
    private static org.apache.logging.log4j.Logger logger = LogManager.getLogger(UserServiceImpl.class);

    @Autowired
    private UserMapper userMapper;

    @Override
    public User validateUser(String username, String password) {
//        UserExample userExample = new UserExample();
//        userExample.createCriteria().andUsernameEqualTo(username.trim());
//        List<User> users = userMapper.selectByExample(userExample);
//        if(null == users || users.size() < 1){
//            return null;
//        }
//
//        if (users.size() > 1) {
//            logger.error(String.format("用户名为 %s 的用户查询出多条记录，默认选择第一个！", username));
//        }
//
//        User user = users.get(0);
//        if (user.getPassword().equals(password)) {
//            return user;
//        }

        return null;
    }
}
